home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-11 | 10.8 KB | 391 lines | [TEXT/MPS ] |
- /*
- File: Link.h
-
- Contains: Link Classes Definition
-
- Written by: Dave Stafford and Mike Halpin
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- // -- DrawEditor Includes --
-
- #ifndef _LINK_
- #define _LINK_
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- #ifndef _DRAWCONTENT_
- #include "DrawContent.h"
- #endif
-
-
- //=============================================================================
- // Forward Declarations
- //=============================================================================
- class CSelection;
- class COrderedList;
- class CPromise;
- class CShape;
- class CCreateLinkCommand;
- class CPasteLinkCommand;
- class CDragShapeCommand;
-
-
- //=============================================================================
- // class CPublishLink
- //=============================================================================
-
- class CPublishLink
- {
- public:
- // -- Init --
-
- CPublishLink( ODUpdateID updateID,
- CSelection* selection,
- COrderedList* shapeList,
- COrderedList* subscribeLinks);
-
- CPublishLink (CSelection* selection);
-
- virtual ~CPublishLink();
-
- // -- State --
- void Publish(Environment* ev);
- ODBoolean PostCloneInternalizeLink( Environment* ev,
- ODDraft* toDraft,
- CShape* shape);
-
- void Unpublish(Environment* ev);
-
- void AddToPart(Environment* ev);
- void RemoveFromPart(Environment *ev);
-
- void SetSourcePart(Environment* ev);
-
- ODBoolean WasRemoved() const;
- ODBoolean CanDelete() const;
- ODBoolean IsPublished();
-
- void SetHasCommandOutstanding(ODBoolean hasCommand);
- ODBoolean GetHasCommandOutstanding();
-
- // -- Updating --
- void ContentUpdated( Environment* ev,
- ODUpdateID updateID,
- ODBoolean forceUpdate = kODFalse);
-
- void ExternalizeLinkContent(Environment* ev, ODStorageUnit* linkSU);
-
- // -- Content --
- void AddShape(CShape* shape);
- void AddShape(Environment* ev, CShape* shape);
-
- void RemoveShape(CShape *shape);
- void ShapeSelected(ODBoolean selectState);
- ODULong Count();
-
- // -- Data Transfer and Storage --
- void ExternalizeLink(Environment *ev,
- ODStorageUnit* su,
- CCloneInfo* cloneInfo);
-
- ODBoolean InternalizeLink(Environment *ev,
- ODStorageUnit *su,
- CCloneInfo *cloneInfo,
- CShape** shapeTable);
-
- // -- User Interface --
- void ShowLinkInfoDialog(Environment* ev);
- void RevealLink(Environment* ev);
-
- // -- Misc Accessors --
- ODLinkSource* GetODLinkSource() const;
-
- ODUpdateID GetUpdateID() const;
- ODUpdateID GetPendingID() const;
- void SetPendingID(ODUpdateID id);
-
- private:
- ODLinkSource* fODLinkSource;
- ODID fODID;
-
- ODUpdateID fUpdateID;
- ODUpdateID fPendingID;
-
- CSelection* fSelection;
- DrawEditor* fDrawEditor;
-
- COrderedList* fShapeList;
- CDrawContent* fPublishContent;
- CPromise* fPromise;
- COrderedList* fSubscribeLinks; // temporary list when link is not in content
-
- ODBoolean fWasRemoved;
- ODBoolean fPublished;
- ODBoolean fHasCommandOutstanding;
- ODBoolean fNewlyPublished;
-
- ODUShort fSelectedCount;
-
- };
-
- // Typedef for linkspec data
- typedef struct
- {
- ODUpdateID fUpdateID;
- CDragShapeCommand* fCommand;
-
- } LinkSpecData;
-
-
- //=============================================================================
- // class CSubscribeLink
- //=============================================================================
-
- class CSubscribeLink
- {
- public:
- // -- Init --
- CSubscribeLink( ODLink* odLink,
- CSelection* selection,
- ODLinkInfo& linkInfo,
- ODPasteAsResult& paResult,
- ODBoolean defaultIsMerge);
-
- CSubscribeLink(CSelection* selection);
-
- virtual ~CSubscribeLink();
-
- // -- Link State --
- void Subscribe(Environment* ev);
- ODBoolean PostCloneInternalizeLink( Environment* ev,
- ODDraft* toDraft,
- CShape* shape);
-
- void Unsubscribe(Environment* ev);
-
- void Publish(Environment* ev, CPublishLink* publishLink);
- void Unpublish(Environment* ev, CPublishLink* publishLink);
-
- void AddToPart(Environment *ev);
- void RemoveFromPart(Environment* ev, ODBoolean doRemove = kODTrue);
-
- void Register(Environment* ev);
- void Unregister(Environment* ev);
- ODBoolean IsRegistered();
-
- void SetCommand(CPasteLinkCommand* command);
-
- // -- Link Content --
- void LinkUpdated(Environment* ev, ODUpdateID id);
-
- void AddShape(Environment* ev, CShape* shape);
- void AddShape(CShape* shape);
- void RemoveShape(CShape* shape);
-
- void ShapeSelected(ODBoolean selectState);
-
- void AddToSelection(Environment* ev, ODBoolean drawHandles);
- void RemoveShapes(Environment* ev, ODBoolean commit);
-
- // -- Data Transfer and Storage --
- void ExternalizeLink(Environment *ev, ODStorageUnit* su, CCloneInfo* cloneInfo);
- ODBoolean InternalizeLink( Environment *ev, ODStorageUnit *su, CCloneInfo *cloneInfo, CShape** shapeTable);
-
- // -- User Interface --
- void ShowCantEditDialog(Environment* ev);
- void ShowLinkInfoDialog(Environment* ev);
-
- void SetOriginPoint(ODPoint newOrigin);
-
- // -- Misc. Accessors --
- ODLink* GetODLink() const;
- COrderedList* GetPublishLinks();
- ODULong Count();
-
-
- private:
- ODLink* fODLink;
- ODID fODID;
-
- CSelection* fSelection;
- DrawEditor* fDrawEditor;
-
- COrderedList* fShapeList;
- CSubscribeContent* fSubscribeContent;
- COrderedList* fPublishLinks;
-
- ODLinkInfo fLinkInfo;
- ODPasteAsResult fPasteAsResult;
- ODBoolean fDefaultIsMerge;
-
-
- ODBoolean fRegistered;
- CPasteLinkCommand* fCommand;
- ODBoolean fWasRemoved; // Was link removed from the part using RemoveFromPart?
- ODBoolean fRemovedShapes; // Did the link remove shapes from the part in RemoveFromPart?
-
- ODPoint fOriginPoint;
- ODUShort fSelectedCount;
- };
-
- //=============================================================================
- // CPublishLink Inlines
- //=============================================================================
-
- //-----------------------------------------------------------------------------
- // CPublishLink::GetODLinkSource
- //-----------------------------------------------------------------------------
- inline ODLinkSource* CPublishLink::GetODLinkSource() const
- {
- return fODLinkSource;
- }
-
- //-----------------------------------------------------------------------------
- // CPublishLink::CanDelete
- //
- // Description: If the link is neither published nor cached in a command
- // then it's ok to delete it.
- //-----------------------------------------------------------------------------
- inline ODBoolean CPublishLink::CanDelete() const
- {
- return !fPublished && !fHasCommandOutstanding;
- }
-
- //-----------------------------------------------------------------------------
- // CPublishLink::GetUpdateID
- //-----------------------------------------------------------------------------
- inline ODUpdateID CPublishLink::GetUpdateID() const
- {
- return fUpdateID;
- }
-
- //-----------------------------------------------------------------------------
- // CPublishLink::GetPendingID
- //-----------------------------------------------------------------------------
- inline ODUpdateID CPublishLink::GetPendingID() const
- {
- return fPendingID;
- }
-
- //-----------------------------------------------------------------------------
- // CPublishLink::SetPendingID
- //-----------------------------------------------------------------------------
- inline void CPublishLink::SetPendingID(ODUpdateID id)
- {
- fPendingID = id;
- }
-
- //---------------------------------------------------------------------------------------
- // CPublishLink::WasRemoved
- //
- // Description: kODTrue if RemoveFromPart was called and AddToPart hasn't been called
- // since.
- //---------------------------------------------------------------------------------------
-
- inline ODBoolean CPublishLink::WasRemoved() const
- {
- return fWasRemoved;
- }
-
- //---------------------------------------------------------------------------------------
- // CPublishLink::IsPublished
- //
- // Description: kODTrue if Publish or PostCloneInternalizeLink was called, and Unpublish
- // has not been called since then.
- //---------------------------------------------------------------------------------------
-
- inline ODBoolean CPublishLink::IsPublished()
- {
- return fPublished;
- }
-
-
- //---------------------------------------------------------------------------------------
- // CPublishLink::SetHasCommandOutstanding
- //
- // Description: Set fHasCommandOutstanding to indicate if there is a reference to
- // this in a command object.
- //---------------------------------------------------------------------------------------
-
- inline void CPublishLink::SetHasCommandOutstanding(ODBoolean hasCommand)
- {
- fHasCommandOutstanding = hasCommand;
- }
-
-
- //---------------------------------------------------------------------------------------
- // CPublishLink::GetHasCommandOutstanding
- //
- // Description: kODTrue if this is refernced in a command object.
- //---------------------------------------------------------------------------------------
-
- inline ODBoolean CPublishLink::GetHasCommandOutstanding()
- {
- return fHasCommandOutstanding;
- }
-
- //=============================================================================
- // CSubscribeLink Inlines
- //=============================================================================
-
- //-----------------------------------------------------------------------------
- // CSubscribeLink::GetODLink
- //-----------------------------------------------------------------------------
- inline ODLink* CSubscribeLink::GetODLink() const
- {
- return fODLink;
- }
-
- //-----------------------------------------------------------------------------
- // CSubscribeLink::IsRegistered
- //-----------------------------------------------------------------------------
-
- inline ODBoolean CSubscribeLink::IsRegistered()
- {
- return fRegistered;
- }
-
-
- //-----------------------------------------------------------------------------
- // CSubscribeLink::SetCommand
- //
- // Description: Set the fCommand field for adding a kODEndAction asynchronously
- //-----------------------------------------------------------------------------
-
- inline void CSubscribeLink::SetCommand(CPasteLinkCommand* command)
- {
- fCommand = command;
- }
-
- //-----------------------------------------------------------------------------
- // CSubscribeLink::SetOriginPoint
- //
- // Description: Set the default location for the next update to be drawn at
- // used when 'Dropping' a link.
- //-----------------------------------------------------------------------------
-
- inline void CSubscribeLink::SetOriginPoint(ODPoint newOrigin)
- {
- fOriginPoint = newOrigin;
- }
-
- //-----------------------------------------------------------------------------
- // CSubscribeLink::GetPublishLinks
- //
- // Description: Return the list of publishers in which this subscriber is
- // contained.
- //-----------------------------------------------------------------------------
-
- inline COrderedList* CSubscribeLink::GetPublishLinks()
- {
- return fPublishLinks;
- }
-
- #endif
-
-
-